package com.leoman.plz_p.adapter;

import android.content.Context;
import android.view.View;

import com.leoman.plz_p.R;
import com.leoman.plz_p.module.bean.TestBean;

import cn.com.corelib.utils.adapter.BaseAdapterHelper;
import cn.com.corelib.utils.adapter.normal.QuickAdapter;

/**
 * Created by guoh on 2018/9/26.
 */
public class CourseTestAdapter extends QuickAdapter<TestBean.ListBeanX> {

    private CourseTestClassAdapter adapter;

    public CourseTestAdapter(Context context) {
        super(context, R.layout.item_test_point);
    }

    @Override
    protected void convert(final BaseAdapterHelper helper, TestBean.ListBeanX item, int position) {
        helper.setText(R.id.tv_title_name,item.getTitle());
        adapter=new CourseTestClassAdapter(context);
        adapter.replaceAll(item.getList());
        helper.setAdapter(R.id.ls_class,adapter);

        helper.getView().setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                helper.setVisible(R.id.ls_class,helper.getView(R.id.ls_class).getVisibility()==View.VISIBLE?false:true);
                if (helper.getView(R.id.ls_class).getVisibility()==View.VISIBLE){
                    helper.setBackgroundRes(R.id.iv_title_open,R.mipmap.icon_up_gary);
                    helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_one_to_one);
                }else {
                    helper.setBackgroundRes(R.id.iv_title_open,R.mipmap.icon_down_gary);
                    helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_zero_to_four);
                }
            }
        });

        helper.getView(R.id.iv_title_open).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                helper.setVisible(R.id.ls_class,helper.getView(R.id.ls_class).getVisibility()==View.VISIBLE?false:true);
                if (helper.getView(R.id.ls_class).getVisibility()==View.VISIBLE){
                    helper.setBackgroundRes(R.id.iv_title_open,R.mipmap.icon_up_gary);
                    helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_one_to_one);
                }else {
                    helper.setBackgroundRes(R.id.iv_title_open,R.mipmap.icon_down_gary);
                    helper.setBackgroundRes(R.id.iv_title_progress,R.mipmap.icon_zero_to_four);
                }
            }
        });
    }
}
